﻿<UserControl x:Class="Rio.Framework.Pages.Workflow.WorkflowDashboardHistoric"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
             xmlns:workflow="clr-namespace:Rio.Framework.Pages.Workflow"
             xmlns:models="clr-namespace:Rio.Framework.Pages.Workflow.Models"
             xmlns:conv="clr-namespace:Rio.Framework.Pages.Helpers.Converter"
             xmlns:sys="clr-namespace:System;assembly=mscorlib"
             xmlns:utils="clr-namespace:Rio.Framework.Pages.AppCode.Helpers.Utils"
             x:Name="workflowDashboardHistoric"
             mc:Ignorable="d">

    <UserControl.Resources>
        <conv:WorkflowStateToImageConverter x:Key="WorkflowStateToImageConverter" />
        <utils:WorkflowInstanceGridViewStyleSelector x:Key="WorkflowGridViewReadStyleSelector" />
    </UserControl.Resources>

    <Grid x:Name="LayoutRoot">
        <telerik:RadGridView Name="GridHisto"
                             ItemsSource="{Binding WorkflowHistoric, ElementName=workflowDashboardHistoric, Mode=TwoWay}"
                             AutoGenerateColumns="False"
                             ShowGroupPanel="False"
                             CanUserDeleteRows="False"
                             CanUserFreezeColumns="False"
                             CanUserInsertRows="False"
                             DragElementAction="None"
                             RowIndicatorVisibility="Collapsed"
                             RowStyleSelector="{StaticResource WorkflowGridViewReadStyleSelector}">

            <telerik:RadGridView.Columns>
                <telerik:GridViewToggleRowDetailsColumn />
                <telerik:GridViewDataColumn x:Name="GridHisto_Etat"
                                            UniqueName="GridHisto_Etat"
                                            Header=""
                                            IsReadOnly="True"
                                            Width="60"
                                            DataMemberBinding="{Binding IsEnded}">
                    <telerik:GridViewDataColumn.CellTemplate>
                        <DataTemplate>
                            <Image Source="{Binding IsEnded, Converter={StaticResource WorkflowStateToImageConverter}}"
                                   HorizontalAlignment="Center"
                                   VerticalAlignment="Center"
                                   Width="20"
                                   Height="20" />
                        </DataTemplate>
                    </telerik:GridViewDataColumn.CellTemplate>
                    <telerik:GridViewDataColumn.FilteringControl>
                        <workflow:GridFilterStateControl x:Name="GridFilterStateControl" />
                    </telerik:GridViewDataColumn.FilteringControl>
                </telerik:GridViewDataColumn>
                <telerik:GridViewDataColumn UniqueName="GridHisto_StateLabel"
                                            Header=""
                                            IsReadOnly="True"
                                            DataMemberBinding="{Binding StateLabel, Mode=TwoWay}">
                    <telerik:GridViewDataColumn.FilteringControl>
                        <workflow:WorkflowStateCustomFilter  x:Name="WorkflowStateCustomFilter" />
                    </telerik:GridViewDataColumn.FilteringControl>
                </telerik:GridViewDataColumn>
                <telerik:GridViewDataColumn UniqueName="GridHisto_Date"
                                            IsReadOnly="True"
                                            DataMemberBinding="{Binding CreatedOn, ElementName=workflowDashboardHistoric, Mode=TwoWay}" />
                <telerik:GridViewDataColumn UniqueName="GridHisto_FlowName"
                                            IsReadOnly="True"
                                            DataMemberBinding="{Binding DefinitionName, ElementName=workflowDashboardHistoric, Mode=TwoWay}" />
                <telerik:GridViewDataColumn UniqueName="GridHisto_Event"
                                            IsReadOnly="True"
                                            DataMemberBinding="{Binding StartingConditionLabel, ElementName=workflowDashboardHistoric, Mode=TwoWay}" />
                <telerik:GridViewDataColumn UniqueName="GridHisto_TriggeredBy"
                                            IsReadOnly="True"
                                            DataMemberBinding="{Binding SendedBy, ElementName=workflowDashboardHistoric, Mode=TwoWay}" />
                <telerik:GridViewDataColumn UniqueName="GridHisto_Receivers"
                                            IsReadOnly="True"
                                            Width="400"
                                            DataMemberBinding="{Binding Receivers, ElementName=workflowDashboardHistoric, Mode=TwoWay}" />
                <telerik:GridViewDataColumn UniqueName="GridHisto_Receiver"
                                            IsReadOnly="True"
                                            DataMemberBinding="{Binding GroupName, ElementName=workflowDashboardHistoric, Mode=TwoWay}" />
            </telerik:RadGridView.Columns>

            <telerik:RadGridView.RowDetailsTemplate>
                <DataTemplate>
                    <Grid Name="DocumentsDetail"
                          Margin="10,0,10,10"
                          DataContext="{Binding Value}">
                        <telerik:RadGridView AutoGenerateColumns="False"
                                             ShowColumnHeaders="False"
                                             ShowGroupPanel="False"
                                             Loaded="DocumentsDetailLoaded"
                                             RowIndicatorVisibility="Collapsed"
                                             HorizontalGridLinesBrush="{x:Null}"
                                             VerticalGridLinesBrush="{x:Null}"
                                             CanUserDeleteRows="False"
                                             CanUserInsertRows="False"
                                             CanUserFreezeColumns="False"
                                             GridLinesVisibility="None">

                            <telerik:RadGridView.Columns>
                                <telerik:GridViewToggleRowDetailsColumn />
                                <telerik:GridViewDataColumn IsReadOnly="True"
                                                            DataMemberBinding="{Binding Name}" />
                            </telerik:RadGridView.Columns>

                            <telerik:RadGridView.RowDetailsTemplate>
                                <DataTemplate>
                                    <Grid Margin="10,0,10,10"
                                          DataContext="{Binding}">
                                        <telerik:RadGridView x:Name="DocumentHistoricGridView"
                                                             Loaded="DocumentHistoricGridViewLoaded"
                                                             AutoGenerateColumns="False"
                                                             CanUserDeleteRows="False"
                                                             CanUserFreezeColumns="False"
                                                             CanUserInsertRows="False"
                                                             DragElementAction="None"
                                                             RowIndicatorVisibility="Collapsed"
                                                             ShowGroupPanel="False">

                                            <telerik:RadGridView.Columns>
                                                <telerik:GridViewDataColumn IsReadOnly="True"
                                                                            UniqueName="DocumentHistoricGridView_DateAction"
                                                                            DataMemberBinding="{Binding DateAction}"
                                                                            Header="Date" />
                                                <telerik:GridViewDataColumn IsReadOnly="True"
                                                                            UniqueName="DocumentHistoricGridView_Actionlabel"
                                                                            DataMemberBinding="{Binding Actionlabel}"
                                                                            Header="Action du flux" />
                                                <telerik:GridViewDataColumn IsReadOnly="True"
                                                                            UniqueName="DocumentHistoricGridView_HistoUserFullName"
                                                                            DataMemberBinding="{Binding HistoUserFullName}"
                                                                            Header="Utilisateur" />
                                                <telerik:GridViewDataColumn IsReadOnly="True"
                                                                            UniqueName="DocumentHistoricGridView_HistoGroupName"
                                                                            DataMemberBinding="{Binding HistoGroupName}"
                                                                            Header="Groupe" />
                                                <workflow:WorkflowCommentColumn  IsReadOnly="True"
                                                                                 UniqueName="DocumentHistoricGridView_Comment"
                                                                                 DataMemberBinding="{Binding Comment}"
                                                                                 Header="Commentaire" />
                                            </telerik:RadGridView.Columns>
                                        </telerik:RadGridView>
                                    </Grid>
                                </DataTemplate>
                            </telerik:RadGridView.RowDetailsTemplate>

                        </telerik:RadGridView>
                    </Grid>
                </DataTemplate>
            </telerik:RadGridView.RowDetailsTemplate>

        </telerik:RadGridView>
        <telerik:RadBusyIndicator x:Name="busyIndicator" />
    </Grid>
</UserControl>
